//
//  CourtTableView.m
//  HarmonizePub
//
//  Created by rzhy on 2016/10/10.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "CourtTableView.h"
#import "CourtTableViewCell.h"

static NSString * const CellIdentifier = @"Cell";

@interface CourtTableView () <UITableViewDataSource, UITableViewDelegate>

@end

@implementation CourtTableView

+ (instancetype)tableView {
    return [[NSBundle mainBundle] loadNibNamed:@"CourtTableView" owner:nil options:nil].lastObject;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.layer.cornerRadius = 5.0f;
    self.layer.masksToBounds = YES;
    self.layer.borderWidth = 0.5f;
    self.layer.borderColor = [UIColor lightGrayColor].CGColor;
    UINib *nib = [UINib nibWithNibName:[CourtTableViewCell registerName] bundle:nil];
    [self registerNib:nib forCellReuseIdentifier:CellIdentifier];
    self.dataSource = self;
    self.delegate = self;
}

- (void)setDataArray:(NSArray *)dataArray {
    _dataArray = dataArray;
    [self reloadData];
}

#pragma mark - tableView delegate/dataSource Method
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CourtTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    [cell setCellShowDataWithDataDictionary:_dataArray[indexPath.row]];
    return cell;
}

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}

@end
